/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.nii.qlks.GUI;

import edu.nii.qlks.ControlLayer.KhachHangControl;
import edu.nii.qlks.ControlLayer.PhieuDenControl;
import edu.nii.qlks.DataTransferObject.KhachHangInfo;
import edu.nii.qlks.DataTransferObject.LoaiKhachHangInfo;
import edu.nii.qlks.DataTransferObject.PhieuDenInfo;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator;

/**
 *
 * @author KUUT
 */
public class Jinternal_TimkiemKhachhang extends javax.swing.JInternalFrame {

    Vector table_record;
    Vector table_title;
    KhachHangControl khachhang_control;
    KhachHangInfo khachhang_info;
    LoaiKhachHangInfo loaikhach_info;
    static int kiemtrathue_tra = 0;
    static int kiemtrathue = 1;
    static int kiemtratra = 2;
    
    public Jinternal_TimkiemKhachhang() throws Exception{
        initComponents();
        
        table_record = new Vector();
        table_title = new Vector();
        khachhang_control = new KhachHangControl();
        khachhang_info = new KhachHangInfo();
        loaikhach_info = new LoaiKhachHangInfo();
                  
        table_title.add("STT");
        table_title.add("Tên khách hàng");
        table_title.add("Tên loại khách hàng");
        table_title.add("Phòng");
        table_title.add("Ngày thuê");
        table_title.add("Ngày trả");
        table_title.add("CMND");
        table_title.add("Địa chỉ");
        
        comboboxControl();
        LayDS_TimKiem();
        KeyPress();
//        jCheckBox_dangthue.setSelected(true);
//        kiemtrathue_tra = kiemtrathue;
    }
    
    public void comboboxControl() throws Exception{
        
        jComboBox_Tenkhachhang.setModel(new DefaultComboBoxModel(khachhang_control.LayTenKhachhang()));
        jComboBox_Tenkhachhang.insertItemAt("", 0);
        jComboBox_Tenkhachhang.setSelectedIndex(0);
        
        jComboBox_CMND.setModel(new DefaultComboBoxModel(khachhang_control.LayCMND()));
        jComboBox_CMND.insertItemAt("", 0);
        jComboBox_CMND.setSelectedIndex(0);
        
        jComboBox_tenloaikhachhang.setModel(new DefaultComboBoxModel(khachhang_control.LayTenLoaiKhachHang()));
        jComboBox_tenloaikhachhang.insertItemAt("", 0);
        jComboBox_tenloaikhachhang.setSelectedIndex(0);
        
        
        //Tự động hiện từ khi bấm chữ trên Combobox
        AutoCompleteDecorator.decorate(this.jComboBox_CMND);
        AutoCompleteDecorator.decorate(this.jComboBox_Tenkhachhang);
        AutoCompleteDecorator.decorate(this.jComboBox_tenloaikhachhang);
    }
    
    public void LayDS_TimKiem() throws Exception{
        table_record = khachhang_control.TimKiemKhachHangDangthue(khachhang_info, loaikhach_info);
        jXTable_DSLoaiphong.setModel(new DefaultTableModel(table_record, table_title));
    }
    
    public void LayDS_TimkiemDatra() throws Exception{
        table_record = khachhang_control.TimKiemKhachHangDatra(khachhang_info, loaikhach_info);
        jXTable_DSLoaiphong.setModel(new DefaultTableModel(table_record, table_title));
    }

    public void clear(){
        jComboBox_Tenkhachhang.setSelectedIndex(0);
        jComboBox_tenloaikhachhang.setSelectedIndex(0);
        jComboBox_CMND.setSelectedIndex(0);
    }
    
    public void KeyPress(){
        //Enter Combobox Tên phòng
        jComboBox_Tenkhachhang.getEditor().getEditorComponent().addKeyListener(new KeyAdapter() 
        {
            @Override
            public void keyPressed(KeyEvent evt)
            {
                if(evt.getKeyCode() == KeyEvent.VK_ENTER)
                {
                    try{
                        timkiemPublic();
                    }catch(Exception e){
                        JOptionPane.showMessageDialog(null, "Không tim thấy"
                                , "Warning", JOptionPane.WARNING_MESSAGE);
                    }
                }
            }
        });
        
        //Enter Combobox Tên loại phòng
        jComboBox_tenloaikhachhang.getEditor().getEditorComponent().addKeyListener(new KeyAdapter() 
        {
            @Override
            public void keyPressed(KeyEvent evt)
            {
                if(evt.getKeyCode() == KeyEvent.VK_ENTER)
                {
                    try{
                        timkiemPublic();
                    }catch(Exception e){
                        JOptionPane.showMessageDialog(null, "Không tim thấy"
                                , "Warning", JOptionPane.WARNING_MESSAGE);
                    }
                }
            }
        });
        
        //Enter Combobox Tình trạng
        jComboBox_CMND.getEditor().getEditorComponent().addKeyListener(new KeyAdapter() 
        {
            @Override
            public void keyPressed(KeyEvent evt)
            {
                if(evt.getKeyCode() == KeyEvent.VK_ENTER)
                {
                    try{
                        timkiemPublic();
                    }catch(Exception e){
                        JOptionPane.showMessageDialog(null, "Không tim thấy"
                                , "Warning", JOptionPane.WARNING_MESSAGE);
                    }
                }
            }
        });
    }
    
    
    public void timkiemPublic()throws Exception{
        //Lay gia tri ten khach hang
        if(jComboBox_Tenkhachhang.getSelectedIndex() < 0 ){
            //Lấy Giá trị từ combobox khi gõ từ
            String tenkh = (String)jComboBox_Tenkhachhang.getEditor().getItem().toString();
            khachhang_info.setTenKhachHang(tenkh);
        }else if(jComboBox_Tenkhachhang.getSelectedIndex() == 0){
            khachhang_info.setTenKhachHang("");
        }
        else{
            khachhang_info.setTenKhachHang(jComboBox_Tenkhachhang.getSelectedItem().toString().trim());
        }
        
        //Lay gia tri ten loai khach hang
        if(jComboBox_tenloaikhachhang.getSelectedIndex() < 0 ){
            //Lấy Giá trị từ combobox khi gõ từ
            String tenloaikh = (String)jComboBox_tenloaikhachhang.getEditor().getItem().toString();
            loaikhach_info.setTenLoaiKhach(tenloaikh);
        }else if(jComboBox_tenloaikhachhang.getSelectedIndex() == 0){
            loaikhach_info.setTenLoaiKhach("");
        }
        else{
            loaikhach_info.setTenLoaiKhach(jComboBox_tenloaikhachhang.getSelectedItem().toString().trim());
        }

        //Lay gia tri chung minh nhan dan
        if(jComboBox_CMND.getSelectedIndex() < 0 ){
            //Lấy Giá trị từ combobox khi gõ từ
            String cmnd = (String)jComboBox_CMND.getEditor().getItem().toString();
            khachhang_info.setCMND(cmnd);
        }else if(jComboBox_CMND.getSelectedIndex() == 0){
            khachhang_info.setCMND("");
        }
        else{
            khachhang_info.setCMND(jComboBox_CMND.getSelectedItem().toString().trim());
        }
        
        //Kiem tra dang o che do nao dang thue - da tra
        if (kiemtrathue_tra == kiemtrathue) {
            
            try {
                table_record = khachhang_control.TimKiemKhachHangDangthue(khachhang_info, loaikhach_info);
            } catch (Exception ex) {
                Logger.getLogger(Jinternal_TimkiemKhachhang.class.getName()).log(Level.SEVERE, null, ex);
            }
            jXTable_DSLoaiphong.setModel(new DefaultTableModel(table_record, table_title));
            clear();
            
            
        } else if (kiemtrathue_tra == kiemtratra) {
            
            try {
                table_record = khachhang_control.TimKiemKhachHangDatra(khachhang_info, loaikhach_info);
            } catch (Exception ex) {
                Logger.getLogger(Jinternal_TimkiemKhachhang.class.getName()).log(Level.SEVERE, null, ex);
            }
            jXTable_DSLoaiphong.setModel(new DefaultTableModel(table_record, table_title));
            clear();
            
        }
        
    }
    
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jXPanel1 = new org.jdesktop.swingx.JXPanel();
        jXLabel1 = new org.jdesktop.swingx.JXLabel();
        jXPanel2 = new org.jdesktop.swingx.JXPanel();
        jXLabel2 = new org.jdesktop.swingx.JXLabel();
        jXLabel3 = new org.jdesktop.swingx.JXLabel();
        jXLabel4 = new org.jdesktop.swingx.JXLabel();
        jComboBox_Tenkhachhang = new javax.swing.JComboBox();
        jComboBox_CMND = new javax.swing.JComboBox();
        jComboBox_tenloaikhachhang = new javax.swing.JComboBox();
        jCheckBox_dangthue = new javax.swing.JCheckBox();
        jCheckBox_datra = new javax.swing.JCheckBox();
        jXPanel3 = new org.jdesktop.swingx.JXPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jXTable_DSLoaiphong = new org.jdesktop.swingx.JXTable();
        jXButton_Them = new org.jdesktop.swingx.JXButton();

        setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));

        jXPanel1.setBackground(new java.awt.Color(0, 51, 204));

        jXLabel1.setForeground(new java.awt.Color(255, 255, 255));
        jXLabel1.setText("TÌM KIẾM THÔNG TIN KHÁCH HÀNG");
        jXLabel1.setFont(new java.awt.Font("Times New Roman", 1, 24)); // NOI18N

        javax.swing.GroupLayout jXPanel1Layout = new javax.swing.GroupLayout(jXPanel1);
        jXPanel1.setLayout(jXPanel1Layout);
        jXPanel1Layout.setHorizontalGroup(
            jXPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jXPanel1Layout.createSequentialGroup()
                .addGap(241, 241, 241)
                .addComponent(jXLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 450, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(265, Short.MAX_VALUE))
        );
        jXPanel1Layout.setVerticalGroup(
            jXPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jXPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jXLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 29, Short.MAX_VALUE)
                .addContainerGap())
        );

        jXPanel2.setBackground(new java.awt.Color(255, 255, 255));
        jXPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Thông tin loại phòng", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Times New Roman", 1, 18), new java.awt.Color(255, 0, 0))); // NOI18N

        jXLabel2.setText("Tên khách hàng");

        jXLabel3.setText("CMND");

        jXLabel4.setText("Tên loại khách hàng");

        jComboBox_Tenkhachhang.setEditable(true);
        jComboBox_Tenkhachhang.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        jComboBox_CMND.setEditable(true);
        jComboBox_CMND.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        jComboBox_tenloaikhachhang.setEditable(true);
        jComboBox_tenloaikhachhang.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        jCheckBox_dangthue.setBackground(new java.awt.Color(255, 255, 255));
        jCheckBox_dangthue.setText("Đang ở");
        jCheckBox_dangthue.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBox_dangthueActionPerformed(evt);
            }
        });

        jCheckBox_datra.setBackground(new java.awt.Color(255, 255, 255));
        jCheckBox_datra.setText("Đã trả phòng");
        jCheckBox_datra.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBox_datraActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jXPanel2Layout = new javax.swing.GroupLayout(jXPanel2);
        jXPanel2.setLayout(jXPanel2Layout);
        jXPanel2Layout.setHorizontalGroup(
            jXPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jXPanel2Layout.createSequentialGroup()
                .addGap(31, 31, 31)
                .addGroup(jXPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jXLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jXLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(26, 26, 26)
                .addGroup(jXPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jComboBox_Tenkhachhang, 0, 199, Short.MAX_VALUE)
                    .addComponent(jComboBox_CMND, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(95, 95, 95)
                .addGroup(jXPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jXLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jCheckBox_dangthue))
                .addGap(38, 38, 38)
                .addGroup(jXPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jCheckBox_datra)
                    .addComponent(jComboBox_tenloaikhachhang, javax.swing.GroupLayout.PREFERRED_SIZE, 209, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(133, Short.MAX_VALUE))
        );
        jXPanel2Layout.setVerticalGroup(
            jXPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jXPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jXPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jXLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jXLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jComboBox_Tenkhachhang, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jComboBox_tenloaikhachhang, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 42, Short.MAX_VALUE)
                .addGroup(jXPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jXLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jComboBox_CMND, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jCheckBox_dangthue)
                    .addComponent(jCheckBox_datra))
                .addGap(38, 38, 38))
        );

        jXPanel3.setBackground(new java.awt.Color(255, 255, 255));
        jXPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Danh sách loại phòng", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Times New Roman", 1, 18), new java.awt.Color(255, 0, 0))); // NOI18N

        jXTable_DSLoaiphong.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "STT" ,"Tên phòng", "Mã loại phòng", "Đơn giá phòng"
            }
        ));
        jXTable_DSLoaiphong.setEditable(false);
        jXTable_DSLoaiphong.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jXTable_DSLoaiphongMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(jXTable_DSLoaiphong);

        javax.swing.GroupLayout jXPanel3Layout = new javax.swing.GroupLayout(jXPanel3);
        jXPanel3.setLayout(jXPanel3Layout);
        jXPanel3Layout.setHorizontalGroup(
            jXPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1)
        );
        jXPanel3Layout.setVerticalGroup(
            jXPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 175, Short.MAX_VALUE)
        );

        jXButton_Them.setBackground(new java.awt.Color(0, 51, 204));
        jXButton_Them.setForeground(new java.awt.Color(255, 255, 255));
        jXButton_Them.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/icon/add.png"))); // NOI18N
        jXButton_Them.setText("TÌM");
        jXButton_Them.setBorderPainted(false);
        jXButton_Them.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jXButton_ThemActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jXPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jXPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jXPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addGap(30, 30, 30))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jXButton_Them, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(281, 281, 281))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jXPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(45, 45, 45)
                .addComponent(jXPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(27, 27, 27)
                .addComponent(jXButton_Them, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(29, 29, 29)
                .addComponent(jXPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jXButton_ThemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jXButton_ThemActionPerformed
        try {
            timkiemPublic();
        } catch (Exception ex) {
            Logger.getLogger(Jinternal_TimkiemKhachhang.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jXButton_ThemActionPerformed

    private void jXTable_DSLoaiphongMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jXTable_DSLoaiphongMouseClicked
        //Kiểm tra đã click vào Bảng danh sách phòng hay không

//        if(jXTable_DSLoaiphong.getSelectedRow() < 0){
//            JOptionPane.showMessageDialog(null, "Vui lòng kích các dòng trong bảng Danh sách Loại phòng"
//                , "Thông tin", JOptionPane.INFORMATION_MESSAGE);
//
//            return;
//        }
//
//        try{
//            //Chọn row trong table
//            row = jXTable_DSLoaiphong.getSelectedRow();
//
//            //Gán giá trị từ bảng cho các đối tượng
//            jXTextField_Tenloaiphong.setText(jXTable_DSLoaiphong.getValueAt(row, 1).toString().trim());
//            jXTextField_Maloaiphong.setText(jXTable_DSLoaiphong.getValueAt(row, 2).toString().trim());
//            float a = Float.parseFloat(jXTable_DSLoaiphong.getValueAt(row, 3).toString().trim());
//            String s = String.valueOf((int)a);
//            jXTextField_Dongia.setText(s);
//            huy();
//        }catch(Exception e){
//
//        }
    }//GEN-LAST:event_jXTable_DSLoaiphongMouseClicked

    private void jCheckBox_dangthueActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox_dangthueActionPerformed
        try {
            timkiemPublic();
            kiemtraCheckbox();
            if(jCheckBox_dangthue.isSelected() == false){
                jCheckBox_datra.setSelected(true);
            }
            else{
                jCheckBox_datra.setSelected(false);
            }
            kiemtraCheckbox();
        } catch (Exception ex) {
            Logger.getLogger(Jinternal_TimkiemKhachhang.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jCheckBox_dangthueActionPerformed

    private void jCheckBox_datraActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox_datraActionPerformed
        try {
            timkiemPublic();
        } catch (Exception ex) {
            Logger.getLogger(Jinternal_TimkiemKhachhang.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        kiemtraCheckbox();
        if(jCheckBox_datra.isSelected() == false ){
            jCheckBox_dangthue.setSelected(true);
        }
        else{
            jCheckBox_dangthue.setSelected(false);
        }
        kiemtraCheckbox();
    }//GEN-LAST:event_jCheckBox_datraActionPerformed

    public void kiemtraCheckbox(){
        if(jCheckBox_dangthue.isSelected() == true){
            kiemtrathue_tra = kiemtrathue;
            try {
                LayDS_TimKiem();
            } catch (Exception ex) {
                Logger.getLogger(Jinternal_TimkiemKhachhang.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        else{
            kiemtrathue_tra = kiemtratra;
            try {
                LayDS_TimkiemDatra();
            } catch (Exception ex) {
                Logger.getLogger(Jinternal_TimkiemKhachhang.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        
        
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JCheckBox jCheckBox_dangthue;
    private javax.swing.JCheckBox jCheckBox_datra;
    private javax.swing.JComboBox jComboBox_CMND;
    private javax.swing.JComboBox jComboBox_Tenkhachhang;
    private javax.swing.JComboBox jComboBox_tenloaikhachhang;
    private javax.swing.JScrollPane jScrollPane1;
    private org.jdesktop.swingx.JXButton jXButton_Them;
    private org.jdesktop.swingx.JXLabel jXLabel1;
    private org.jdesktop.swingx.JXLabel jXLabel2;
    private org.jdesktop.swingx.JXLabel jXLabel3;
    private org.jdesktop.swingx.JXLabel jXLabel4;
    private org.jdesktop.swingx.JXPanel jXPanel1;
    private org.jdesktop.swingx.JXPanel jXPanel2;
    private org.jdesktop.swingx.JXPanel jXPanel3;
    private org.jdesktop.swingx.JXTable jXTable_DSLoaiphong;
    // End of variables declaration//GEN-END:variables
}
